<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<%@ include file="/common/commons.jsp"%>
<%@ include file="/common/meta.jsp"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title>用户管理</title>
	<script>
		$(document).ready(function(){
			//聚焦第一个输入框
			$("#loginName").focus();
			//为inputForm注册validate函数
			$("#inputForm").validate({
				rules: { 
					loginName: { 
        				required: true, 
        				remote: "${ctx}/security/user!checkLoginName.action?oldLoginName="+encodeURIComponent('${loginName}')
    				},
          			//name: "required",
          			password: {
    					required: true,
    					minlength:3
    				}, 
    				passwordConfirm: {
    					equalTo:"#password"
    				},
    				email: {
    					required:true,
    					email:true
    				},
    				telNumber:"required",
    				forgotQuestion:"required",
    				forgotAnswer:"required"
				},
				messages: {
					loginName: {
						remote: "用户名已存在"
					},
					passwordConfirm: {
						equalTo: "输入与上面相同的密码"
					},
					email: {
						required: "邮箱必须填写"
					},
					telNumber: {
						required: "联系电话必须填写，可以是座机或手机"
					},
					forgotQuestion: {
						required: "密码提示问题必须填写，这是找回密码的依据"
					},
					forgotAnswer: {
						required: "提示问题答案必须填写"
					}
				}
			});
		});
	
	function modifyPassword(){
	   document.all["changePassword"].value="1";
	}
	</script>
</head>

<body>
<h3><s:if test="id == null">新增</s:if><s:else>修改</s:else>用户</h3>
<div id="inputDiv">
<form id="inputForm" action="user!save.action" method="post">
<input type="hidden" name="id" value="${id}" />
<input type="hidden" name="changePassword" value="0" />
<table>
	<tr>
		<td>用户名:</td>
		<td><input type="text" name="loginName" id="loginName" class="inputText" value="${loginName}" <c:if test="${id!=null}">disabled="disabled"</c:if>  /></td>
	</tr>
	<tr>
		<td>密码:</td>
		<td><input type="password" id="password" name="password" class="inputText" value="${password}" onchange="javascript:modifyPassword();" /></td>
	</tr>
	<tr>
		<td>确认密码:</td>
		<td><input type="password" name="passwordConfirm" class="inputText" value="${password}" /></td>
	</tr>
	<tr>
		<td>联系电话:</td>
		<td><input type="text" name="telNumber" class="inputText" value="${telNumber}" /></td>
	</tr>
	<tr>
		<td>邮箱:</td>
		<td><input type="text" name="email" class="inputText" value="${email}" /></td>
	</tr>
	<tr>
	  	<td>忘记密码提示问题:</td>
	  	<td><input type="text" name="forgotQuestion" class="inputLongText" value="${forgotQuestion}" /></td>
	</tr>
	<tr>
	  	<td>忘记密码提示问题答案:</td>
	  	<td><input type="text" name="forgotAnswer" class="inputLongText" value="${forgotAnswer}" /></td>
	</tr>
	<tr>
		<td colspan="2">
			<input type="submit" value="提交" />&nbsp; 
			<input type="button" value="取消" onclick="history.back()"/>
		</td>
	</tr>
</table>
</form>
</div>
</body>
</html>